<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<table border="">
  <caption>用户列表</caption>
  <tr>
    <th>用户名</th><th>密码</th><th>昵称</th>
  </tr>
</table>
<script>
    let table = document.querySelector("table");
  //准备一个数组 里面装3个用户对象,然后把数组中的信息显示到表中
  let arr = [{username:"tom",password:"123456",nick:"汤姆"},
      {username:"jerry",password:"456789",nick:"杰瑞"},
      {username:"lucy",password:"abcd",nick:"露西"}]
  for (let user of arr) {
      let tr = document.createElement("tr");
      let usernameTd = document.createElement("td");
      let passwordTd = document.createElement("td");
      let nickTd = document.createElement("td");
      //设置td的显示内容
      usernameTd.innerText = user.username;
      passwordTd.innerText = user.password;
      nickTd.innerText = user.nick;
      //把td装进tr
      tr.append(usernameTd,passwordTd,nickTd);
      table.append(tr);
  }
</script>
</body>
</html>